package com.sq.partner.manager.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.sq.partner.manager.dao.FacadeAppBeneficiaryDao;
import com.sq.partner.manager.mybatis.model.FacadeAppBeneficiary;
import com.sq.partner.manager.service.FacadeAppBeneficiaryService;
import com.sq.partner.manager.util.DateUtil;

/**
 * 受益人Service实现类
 * 
 * SQ
 *
 */
@Service
public class FacadeAppBeneficiaryServiceImpl implements
        FacadeAppBeneficiaryService {

    @Resource
    FacadeAppBeneficiaryDao facadeAppBeneficiaryDao;

    /**
     * 保存受益人
     * 
     * @param facadeAppBeneficiary
     * @return
     * @throws Exception
     */
    public FacadeAppBeneficiary saveFacadeAppBeneficiary(
            FacadeAppBeneficiary facadeAppBeneficiary) throws Exception {
        //取得新的受益人编码
        String newClientNo = facadeAppBeneficiaryDao.queryNewSyrClientNo();
        facadeAppBeneficiary.setClientNo(newClientNo);
        facadeAppBeneficiary.setCreatTime(DateUtil.getNowTimestamp());
        facadeAppBeneficiary.setUpdateTime(DateUtil.getNowTimestamp());
        //添加受益人
        facadeAppBeneficiaryDao
                .insertFacadeAppBeneficiary(facadeAppBeneficiary);
        return facadeAppBeneficiary;
    }
    
    /**
     * 根据保单号删除受益人
     * 
     * @param appNo
     * @throws Exception
     */
    @Override
    public void delFacadeAppBeneficiaryByAppNo(String appNo) throws Exception {
        facadeAppBeneficiaryDao.delFacadeAppBeneficiaryByAppNo(appNo);
    }
}
